<template>
  <div>
    <div class="my-body">
      <div class="ipt_a">
        <div style="float: left; line-height: 30px" class="tab_font-size">
          生产批号：
        </div>
        <el-input
          v-model="input"
          placeholder="请输入内容"
          style="width: 130px; height: 50px; float: left"
        ></el-input>
      </div>

      <div class="ipt_a">
        <div style="float: left; line-height: 30px" class="tab_font-size">
          申请日期：
        </div>
        <el-date-picker
          v-model="value1"
          type="date"
          placeholder="选择日期"
          style="width: 130px"
        >
        </el-date-picker>
      </div>

      <div style="float: left">
        <div class="ipt_a">
          <div style="float: left; line-height: 30px" class="tab_font-size">
            入库状态：
          </div>
          <el-select v-model="form.regiona" placeholder="" style="width: 130px">
            <el-option label="全部" value="0"></el-option>
            <el-option label="入库申请" value="1"></el-option>
            <el-option label="入库完成" value="2"></el-option>
          </el-select>
        </div>
        <div class="ipt_a">
          <div style="float: left; line-height: 30px" class="tab_font-size">
            产品类型：
          </div>
          <el-select v-model="form.regionb" placeholder="" style="width: 130px">
            <el-option label="全部" value="0"></el-option>
            <el-option label="...." value="1"></el-option>
            <el-option label="...." value="2"></el-option>
          </el-select>
        </div>
      </div>
      <div>
        <el-button type="primary" plain>查询</el-button>
      </div>
      <div>
        <div style="width: 100%; float: left">
          <el-button type="primary" @click="dialogVisiblerkqs()" plain
            >入库申请</el-button
          >
          <el-button type="danger" plain @click="shanchuli"
            >删除入库申请</el-button
          >
          <el-button type="warning" plain @click="laokuan = true"
            >老款产品入库</el-button
          >
        </div>
        <el-dialog
          title="老款产品入库扫描"
          :visible.sync="laokuan"
          width="50%"
          :before-close="handleClose"
        >
          <div style="width: 100%; height: 550px">
            <div style="width: 100%; float: left; height: 100px">
              <!-- <div>XXXXXXXXXXXXXX</div>
              <div>规格条码：未知</div>
              <div>产品序列：未知</div> -->
            </div>
            <div style="width: 100%; float: left">
              <template>
                <el-table
                  :data="
                    tableData.slice(
                      (currentPage - 1) * pageSize,
                      currentPage * pageSize
                    )
                  "
                 :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
                  border
                  style="width: 100%"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column fixed prop="bianhao" label="产品规格">
                  </el-table-column>

                  <el-table-column prop="enddate" label="产品单价">
                  </el-table-column>
                  <el-table-column prop="name" label="产品数量">
                  </el-table-column>

                  <el-table-column prop="senddate" label="备注">
                  </el-table-column>
                </el-table>
                <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="currentPage"
                  :page-sizes="[5, 10]"
                  :page-size="pageSize"
                  :total="tableData.length"
                  layout="total, sizes, prev, pager, next, jumper"
                >
                </el-pagination>
              </template>
              <div>000/000件</div>
              <div style="margin-top: 30px">
                <el-button type="primary">产品入库提交</el-button>
                <el-button type="warning">放弃返回</el-button>
              </div>
            </div>
          </div>
        </el-dialog>
        <el-dialog
          title="添加积分申请"
          :visible.sync="dialogVisible"
          width="50%"
          :before-close="handleClose"
        >
          <div style="width: 100%">
            <el-form ref="form" :model="form" label-width="100px">
              <!-- <el-form-item label="入库申请编号">
                <el-input v-model="form.name" style="width: 200px"></el-input>
              </el-form-item> -->
              <el-form-item label="入库申请时间">
                <el-date-picker
                  v-model="form.rk_time"
                  format="yyyy-MM-dd HH:mm:ss"
                  value-format="yyyy-MM-dd HH:mm:ss"
                  type="datetime"
                >
                </el-date-picker>
              </el-form-item>
              <el-form-item label="入库类型">
                <el-select v-model="form.type" placeholder="">
                  <el-option label="正常" value="0"></el-option>
                  <el-option label="其他" value="1"></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="生产批号">
                <el-input
                  v-model="form.batch_number"
                  style="width: 200px"
                ></el-input>
              </el-form-item>
              <el-form-item label="生产日期">
                <el-date-picker
                  v-model="form.production_data"
                  type="date"
                    format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                  placeholder="选择日期"
                >
                </el-date-picker>
              </el-form-item>
              <el-form-item label="年份序列号">
                <el-input
                  v-model="form.year_xlh"
                  style="width: 50px"
                ></el-input>
              </el-form-item>

              <el-form-item label="灭菌日期">
                <el-date-picker
                  v-model="form.mj_date"
                   format="yyyy-MM-dd"
                  value-format="yyyy-MM-dd"
                  type="date"
                  placeholder="选择日期"
                  @change="threeYearsAfter"
                >
                </el-date-picker>
              </el-form-item>
              <div
                style="
                  width: 200px;
                  font-size: 14px;
                  font-weight: 600;
                  padding: 20px;
                "
              >
                失效日期： {{ form.exp_date }}
              </div>
              <el-form-item label="灭菌箱编号">
                <el-select v-model="form.pr_mj" placeholder="">
                  <el-option label="04-1" value="1"></el-option>
                  <el-option label="04-2" value="2"></el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="申请起始流水">
                <el-input
                  v-model="form.start_number"
                  style="width: 200px"
                ></el-input>
                <el-button type="success" @click="dialogVisiblexiolie = true"
                  >产品类型</el-button
                >
              </el-form-item>

              <el-form-item label="产品编号">
                <el-select v-model="form.product_codes_id" placeholder="">
                  <el-option
                    v-for="item in product_type"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                    :disabled="item.disabled"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-form>
            <div>
              <el-button type="success" @click="cpmxdiaxuanzhe()"
                >添加产品明细</el-button
              >
              <el-button type="success">删除产品明细</el-button>
              <el-button type="success">清空入库明细</el-button>
            </div>

            <div style="width: 100%">
              <div style="width: 100%">
                <div style="font-size: 16px; font-weight: 600; padding: 20px">
                  商采指标
                </div>
                <el-table
                  :data="form.product_detail"
                  border
                  style="width: 100%"
                 :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
                  height="200"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column prop="specification_number" label="规格">
                  </el-table-column>
                  <el-table-column prop="num" label="入库数量">
                  </el-table-column>
                  <el-table-column prop="remark" label="备注">
                  </el-table-column>
                </el-table>
              </div>
            </div>
            <div class="ipt_b">
              <div style="float: left; line-height: 30px">备注：</div>
              <el-input v-model="form.remark" style="width: 200px"></el-input>
            </div>

            <div style="margin-top: 30px">
              <el-button type="primary" @click="sqruku()">保存</el-button>
              <el-button type="warning"> 返回</el-button>
            </div>
          </div>
        </el-dialog>

        <el-dialog
          title="产品系列表"
          :visible.sync="dialogVisiblexiolie"
          width="30%"
          :before-close="handleClose"
        >
          <el-tree
            :data="datacplx"
            :props="defaultProps"
            :default-expand-all="true"
            @node-click="handleNodeClick"
          ></el-tree>
          <div style="margin-top: 30px">
            <el-button type="primary">确认提交</el-button>
            <el-button type="warning">放弃返回</el-button>
          </div>
        </el-dialog>
        <el-dialog
          title="产品规格明细列表"
          :visible.sync="diaxuanzhe"
          width="50%"
          :before-close="handleClose"
        >
          <div style="width: 100%; height: 550px">
            <div style="width: 30%; float: left">
              <div style="width: 100%; height: 40px; line-height: 40px">
                {{ datacpxl_li.name }}
                <div
                  style="
                    width: 80%;
                    height: 20px;
                    float: left;
                    margin-left: 10%;
                    line-height: 20px;
                  "
                >
                  {{ datacpxl_lizj.name }}
                </div>
              </div>
            </div>
            <div style="width: 70%; float: left">
              <template>
                <el-table
                  :data="specifications_list"
                 :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
                  border
                  ref="multipleTable"
                  tooltip-effect="dark"
                  @selection-change="handleSelectionChange"
                  style="width: 100%"
                  height="300"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column
                    fixed
                    prop="specification_number"
                    label="产品规格"
                  >
                  </el-table-column>

                  <el-table-column prop="price" label="产品单价">
                  </el-table-column>
                  <el-table-column prop="num" label="产品数量">
                    <template slot-scope="scope">
                      <el-input
                        style="width: 100px"
                        v-model="scope.row.num"
                        size="small"
                      ></el-input>
                    </template>
                  </el-table-column>

                  <el-table-column prop="remark" label="备注">
                  </el-table-column>
                </el-table>
                <!-- <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="currentPage"
                  :page-sizes="[100, 200]"
                  :page-size="pageSize"
                  layout="total, sizes, prev, pager, next, jumper"
                >
                </el-pagination> -->
              </template>
              <div style="margin-top: 30px">
                <el-button type="primary" @click="quedintijao()"
                  >确认提交</el-button
                >
                <el-button type="warning">放弃返回</el-button>
              </div>
            </div>
          </div>
        </el-dialog>
        <div style="margin-top: 30px; width: 100%; float: left">
          <div style="width: 100%; float: left">
            <template>
              <el-table
                :data="tableData"
                style="width: 100%"
                border
               :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
                ref="singleTable"
                highlight-current-row
                @current-change="handleCurrentdindanlist"
                height="300"
              >
                <!-- <el-table-column type="selection" width="55"> </el-table-column> -->
                <el-table-column
                  fixed
                  prop="sq_code"
                  label="入库编号"
                  width="155"
                >
                </el-table-column>

                <el-table-column prop="rk_time" label="入库时间" width="155">
                </el-table-column>
                <el-table-column prop="status_txt" label="入库状态" width="155">
                  <template slot-scope="scope">
                    <el-button v-if="scope.row.status_txt == '完成'"
                      >完成入库</el-button
                    >
                    <div v-else>{{ scope.row.status_txt }}</div>
                  </template>
                </el-table-column>
                <el-table-column prop="product_type_name" label="产品类型" width="155">
                </el-table-column>
                <el-table-column
                  prop="batch_number"
                  label="生产批号"
                  width="155"
                >
                </el-table-column>
                <el-table-column
                  prop="production_data"
                  label="生产日期"
                  width="155"
                >
                </el-table-column>
                <el-table-column prop="mj_date" label="灭菌日期" width="155">
                </el-table-column>
                <el-table-column
                  prop="pr_mj_txt"
                  label="灭菌箱编号"
                  width="155"
                >
                </el-table-column>
                <el-table-column prop="exp_date" label="失效日期" width="155">
                </el-table-column>
                <el-table-column
                  prop="start_number"
                  label="申请起始流水"
                  width="155"
                >
                </el-table-column>
                <el-table-column prop="total_num" label="申请入库" width="155">
                </el-table-column>
                <el-table-column prop="senddate" label="实际入库数" width="155">
                </el-table-column>
                <el-table-column prop="remark" label="备注" width="155">
                </el-table-column>
              </el-table>
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[100, 200, 300, 400]"
                :page-size="pageSize"
                :total="total"
                layout="total, sizes, prev, pager, next, jumper"
              >
              </el-pagination>
            </template>
          </div>
        </div>
      </div>
    </div>
    <div class="my-body">
      <div>
        <div>
          <el-button type="primary" @click="rukusaomiao = true" plain
            >入库条码-扫描</el-button
          >
          <el-button type="primary" @click="rukumingxi = true" plain
            >添加入库明细</el-button
          >
          <el-button type="danger" plain @click="shanchumx"
            >删除入库明细</el-button
          >
          <el-button type="warning" plain @click="shengcheng"
            >清空入库明细</el-button
          >

          <span
            >入库信息:产品入库编号【{{ rkname.sq_code }}】系列-类型【{{
              rkname.sq_code
            }}】生产批号【{{ rkname.batch_number }}】</span
          >
        </div>

        <el-dialog
          title="产品规格明细列表"
          :visible.sync="rukumingxi"
          width="50%"
          :before-close="handleClose"
        >
          <div style="width: 100%; height: 550px">
            <div style="width: 30%; float: left">
              <div style="width: 100%; height: 40px; line-height: 40px">
                {{ datacpxl_lia.name }}
                <div
                  style="
                    width: 80%;
                    height: 20px;
                    float: left;
                    margin-left: 10%;
                    line-height: 20px;
                  "
                >
                  {{ datacpxl_lizja.name }}
                </div>
              </div>
            </div>
            <div style="width: 70%; float: left">
              <template>
                <el-table
                  :data="specifications_lista"
                 :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
                  border
                  ref="multipleTablea"
                  tooltip-effect="dark"
                  @selection-change="handleSelectionChangea"
                  style="width: 100%"
                  height="300"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>
                  <el-table-column
                    fixed
                    prop="specification_number"
                    label="产品规格"
                  >
                  </el-table-column>

                  <el-table-column prop="price" label="产品单价">
                  </el-table-column>
                  <el-table-column prop="num" label="产品数量">
                    <template slot-scope="scope">
                      <el-input
                        style="width: 100px"
                        v-model="scope.row.num"
                        size="small"
                      ></el-input>
                    </template>
                  </el-table-column>

                  <el-table-column prop="remark" label="备注">
                  </el-table-column>
                </el-table>
                <!-- <el-pagination
                  @size-change="handleSizeChangea"
                  @current-change="handleCurrentChangea"
                  :current-page="currentPage"
                  :page-sizes="[100, 200]"
                  :page-size="pageSize"
                  layout="total, sizes, prev, pager, next, jumper"
                >
                </el-pagination> -->
              </template>
              <div style="margin-top: 30px">
                <el-button type="primary" @click="quedintijaoa()"
                  >确认提交</el-button
                >
                <el-button type="warning">放弃返回</el-button>
              </div>
            </div>
          </div>
        </el-dialog>
        <el-dialog
          title="产品入库扫描"
          :visible.sync="rukusaomiao"
          width="70%"
          :before-close="handleClose"
        >
          <div style="width: 100%; height: 700px">
            <div>产品系列信息：系列【XXXX系统】类型【xxxx系统-03】</div>
            <div>
              产品入库信息：入库编号【{{ rkname.sq_code }}】产生批号【{{
                rkname.batch_number
              }}】生产日期 【{{ rkname.production_data }}】灭菌日期【{{
                rkname.mj_date
              }}】灭菌箱编号 【{{ rkname.pr_mj_txt }}】
            </div>
            <div style="width: 50%; float: left">
              <div style="font-weight: 600; margin-top: 10px">扫描信息</div>
              <div>
                <div class="ipt_b">
                  <div style="float: left; line-height: 30px">入库日期：</div>
                  <el-date-picker
                    v-model="rukudata"
                    type="date"
                    placeholder="选择日期"
                  >
                  </el-date-picker>
                </div>
                <div class="ipt_a">
                  <div style="float: left; line-height: 30px">批量备注：</div>
                  <el-input
                    v-model="input"
                    placeholder="请输入内容"
                    style="width: 150px; height: 50px; float: left"
                  ></el-input>
                </div>
              </div>
              <template>
                <el-table
                  :data="cpggliistdata"
                 :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
                  border
                  style="width: 100%"
                  ref="singleTablerk"
                  highlight-current-row
                  @current-change="handleCurrentChangerk"
                >
                  <el-table-column fixed prop="bianhao" label="序号">
                  </el-table-column>

                  <el-table-column
                    prop="specification_number"
                    label="类型(规格)"
                  >
                  </el-table-column>
                  <el-table-column prop="num" label="申请数量">
                  </el-table-column>

                  <el-table-column prop="rk_num" label="入库数量">
                  </el-table-column>
                  <el-table-column prop="senddate" label="扫描数量">
                    <template slot-scope="scope">
                      <div>{{scope.row.sm_num }}/{{ scope.row.num -  scope.row.rk_num }}剩余</div>
                      <!-- <el-input
                        style="width: 100px"
                        v-model="scope.row.num"
                        size="small"
                      ></el-input> -->
                    </template>
                  </el-table-column>
                </el-table>
                <!-- <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="currentPage"
                  :page-sizes="[5, 10]"
                  :page-size="pageSize"
                  :total="tableData.length"
                  layout="total, sizes, prev, pager, next, jumper"
                >
                </el-pagination> -->
              </template>
            </div>
            <div style="width: 50%; float: left">
              <div style="font-weight: 600; margin-top: 10px">产品条码</div>

              <div>规格条码</div>
              <div>
                产品序列：
                <el-button type="primary" @click="dianji" plain
                  >开始扫描</el-button
                >
                <el-input
                  autofocus
                  v-model="ipt_sm"
                  ref="inputField"
                  type="text"
                  @input="inputnr"
                ></el-input>
              </div>

              <template>
                <el-table
                  :data="tiaomalist"
                  style="width: 100%"
                  border
                 :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
                  height="400"
                  ref="multipleTabletiaoma"
                  tooltip-effect="dark"
    @selection-change="handleSelectiontiama"
                >
                  <el-table-column type="selection" width="55">
                  </el-table-column>

                  <el-table-column
                    prop="bar_code_show"
                    label="条码"
                    width="305"
                  >
                  </el-table-column>
                  <el-table-column
                    prop="specification_number"
                    label="类型(规格)"
                    width="105"
                  >
                  </el-table-column>

                  <el-table-column prop="senddate" label="状态" width="105">
                  </el-table-column>
                  <el-table-column prop="senddate" label="入库数量" width="65">
                  </el-table-column>
                </el-table>
                <!-- <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="currentPage"
                  :page-sizes="[5, 10]"
                  :page-size="pageSize"
                  :total="tableData.length"
                  layout="total, sizes, prev, pager, next, jumper"
                >
                </el-pagination> -->
              </template>
              <div style="margin-top: 30px">
                <el-button type="primary" @click="cprutijiaoli">产品入库提交</el-button>
                <el-button type="warning" @click="rukusaomiao =false">放弃返回</el-button>
              </div>
            </div>
          </div>
        </el-dialog>
        <div style="margin-top: 30px; width: 100%; float: left">
          <div style="width: 100%; float: left">
            <template>
              <el-table
                :data="
                  cpggliistdata.slice(
                    (currentPagea - 1) * pageSizea,
                    currentPagea * pageSizea
                  )
                "
                style="width: 100%"
                border
                height="250"
               :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
                ref="singleTablea"
                highlight-current-row
                @current-change="handleSelerkmx"
              >
                <!-- <el-table-column type="selection" width="55"> </el-table-column> -->
                <el-table-column
                  fixed
                  prop="specification_number"
                  label="产品规格"
                >
                </el-table-column>

                <el-table-column prop="product_code_name" label="产品编号">
                </el-table-column>
                <el-table-column prop="product_type_name" label="产品类型">
                </el-table-column>
                <el-table-column prop="senddate" label="入库起始流水">
                </el-table-column>
                <el-table-column prop="num" label="入库申请数量">
                </el-table-column>
                <el-table-column prop="rk_num" label="已入库数量">
                </el-table-column>
                <el-table-column prop="senddate" label="条码发行">
                  <template slot-scope="scope">
                    <el-button
                      v-if="scope.row.barcode_status == 0"
                      @click="tiaomafaxing(scope.row.id)"
                      >发行</el-button
                    >
                    <div v-else>已发行</div>
                  </template>
                </el-table-column>
                <el-table-column prop="senddate" label="条码打印">
                  <el-button>打印</el-button>
                </el-table-column>
                <el-table-column prop="senddate" label="备注">
                </el-table-column>
              </el-table>
              <el-pagination
                @size-change="handleSizeChangea"
                @current-change="handleCurrentChangea"
                :current-page="currentPagea"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="pageSizea"
                :total="cpggliistdata.length"
                layout="total, sizes, prev, pager, next, jumper"
              >
              </el-pagination>
            </template>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getData, postData, request } from "@/utils/request.js";
export default {
  data() {
    return {
      key: 1, // 为了能每次切换权限的时候重新初始化指令
      valuesj: 2024,
      dialogVisiblexiolie: false,
      diaxuanzhe: false,
      rukusaomiao: false,
      laokuan: false,
      rukumingxi: false,
      options: [
        {
          value: "1",
          label: "全部",
        },
        {
          value: "2",
          label: "已签收",
        },
        {
          value: "3",
          label: "未签收",
        },
      ],
      data: [
        {
          label: "中国大陆",
          children: [
            {
              label: "上海",
            },
            {
              label: "北京",
            },
            {
              label: "四川",
            },
          ],
        },
      ],
      rklistid: "",
      value1: "",
      defaultProps: {
        children: "children",
        label: "name",
      },
      input: "",
      value: "",
      chanpingguige: false,
      dialogVisible: false,
      dialogVisiblea: false,
      hospital: false,
      area: false,
      currentPage: 1,
      pageSize: 5,
      jinxiaoshang: false,
      shouhuor: false,
      diquxuanzhe: false,
      tableData: [
        {
          bianhao: "PS074107742412L",
          senddate: "2024-05-02",
          enddate: "2024-12-31",
          name: "左心耳",
          province: "完成授权",
          city: "普陀区",
          address: "苏州市中心医院",
          shouqfang: "鹰潭市方园医药有限公司",
          jingxiaos: "鹰潭市方园医药有限公司",
          peisonf: "鹰潭市方园医药有限公司",
          shouqyy: "入院",
          shangcaizhibiao: 3,
        },
      ],
      form: {
        name: "",
        log_type: "1",
        type: "",
        rk_time: "",
        batch_number: "",
        production_data: "",
        mj_date: "",
        exp_date: "",
        start_number: "",
        start_numbera: "",
        product_type_id: "",
        product_codes_id: "",
        total_num: "",
        remark: "",
        product_detail: [],
        year_xlh: "24",
        pr_mj: "",
      },
      sizeForm: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
      },
      datacplx: [],
      product_type: [],
      product_typea: [],
      datacpxl_li: "",
      datacpxl_lizj: "",
      datacpxl_lia: "",
      datacpxl_lizja: "",
      specifications_list: [],
      specifications_lista: [],
      product_detail: [],
      mctiondata: [],
      cpggliistdata: [],
      xuanzhonlist: [],
      //单独选中
      xuanzhonlistdd: [],
      ggid: "",
      total: [],
      pageSize: 100,
      currentPage: 1,
      pageSizea: 10,
      currentPagea: 1,
      rkname: "",
      rukudata: "",
      tiaomalist: [],
      ipt_sm: "",
      barcode_content:[],
      listxzcp:"",
      xuanzhonghuanchuan:[],
    };
  },
  created() {
    this.rukulist();
    this.currentDate();
    this.cplist();
    this.threeYearsAfter();
  },
  computed: {
    lastDayOfYear() {
      let currentDate = new Date();
      let year = currentDate.getFullYear();
      let month = currentDate.getMonth() + 1; // 注意月份从0开始，需要加1
      let day = currentDate.getDate();

      this.form.rk_time = year + "-" + month + "-" + day;
      return year + "-" + month + "-" + day;
    },
  },
  methods: {
    inputnr() {
      console.log(this.ipt_sm);
      var tmmap = this.tiaomalist.map((res) => {
        const temp = res.bar_code_real;
        return temp;
      });
      console.log(tmmap, 6666666);
      tmmap.filter((item, index) => {
        if (item == this.ipt_sm) {
          console.log(index);
          this.toggleSelection([this.tiaomalist[index]]);
          setTimeout(() => {
            this.ipt_sm = "";
          }, 500);
        }
      });
    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTabletiaoma.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTabletiaoma.clearSelection();
      }
      console.log();
    },
    dianji() {
      if (this.tiaomalist == "") {
        this.$message({
          message: "温馨提示：您还没有选择左边的入库信息",
          type: "warning",
        });
      } else {
        this.$nextTick(() => {
          this.$refs.inputField.focus();
        });
      }
    },
    //发行条码
    tiaomafaxing(id) {
      var data = {
        detail_id: id,
        token: localStorage.getItem("token"),
      };
      postData("godown.Log/Faxing ", data).then((res) => {
        console.log(res, 6666666);
      });
    },
    //产品入库提交
    cprutijiaoli(){
      
      var data = {
        log_id: this.rklistid,
        barcode_content: JSON.stringify(this.barcode_content) ,
        token: localStorage.getItem("token"),
      };
      postData("godown.log/addRkProduct", data).then((res) => {
        console.log(res, 6666666);
        this.barcode_content = []
      });
    },
    handleSelectiontiama(val){
          console.log(val)
         
          this.barcode_content = val
          this.listxzcp.sm_num =   val.length
          
          // if(val.length <user){
          //   user.rk_num = user.rrk_num + val.length 
          // }else{
          //   user.rk_num = user.rrk_num + val.length 
          // }
          // if(val == this.barcode_content){
          //   var  user =  this.cpggliistdata.find((item) => item.id === val[0].godown_log_detail_id)
           
          //   if(user.rk_num == this.cpggliistdata[0].num){

          //   }else{
          //     user.rk_num++
          //   }
           
          // }
          // else{
          //   var  user =  this.cpggliistdata.find((item) => item.id === val[0].godown_log_detail_id)
          //   user.rk_num = this.barcode_content.length
          // }
   
      
    },
    handleCurrentChangerk(val) {
      console.log(this.barcode_content)
      if(this.barcode_content.length != 0){
        this.$message({
          message: "扫描的还没有入库",
          type: "warning",
        });
      }else{
        console.log(val);
      this.listxzcp = val
      // if(this.barcode_content == ""){

      // }else{
      //   this.handleCurrentdindanlist(this.rklistid)
      // }
      
      this.tiaomalist = [];
      var data = {
        detail_id: val.id,
        token: localStorage.getItem("token"),
      };
      postData("godown.log/productBarcodeList", data).then((res) => {
        console.log(res, 6666666);
        this.tiaomalist = res.data;
      });
      }
      
     
    },

    //选中入库明细
    handleSelerkmx(val) {
      console.log(val);
      this.ggid = val.id;
    },
    //删除入库明细
    shanchumx() {
      if (this.ggid == "") {
        this.$message({
          message: "选择一条数据再删除",
          type: "warning",
        });
      } else {
        this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            var data = {
              ids: this.ggid,
              token: localStorage.getItem("token"),
            };
            postData("godown.Log/del_detail", data).then((res) => {
              console.log(res, 6666666);
              this.ggid == "";
              this.$message({
                type: "success",
                message: "删除成功!",
              });
            });
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消删除",
            });
          });
      }
    },
    //订单列表点击事件
    
    handleCurrentdindanlist(val) {
      console.log(val);
      this.cplistxqa(val.product_type_id);
      this.rklistid = val.id;
      this.rkname = val;
      var data = {
        log_id: val.id,
        token: localStorage.getItem("token"),
      };
      postData("godown.log/specificationList", data).then((res) => {
        console.log(res, 6666666);
        this.cpggliistdata = res.data;
      });
    },
    shanchuli() {
      this.$confirm("此操作将永久删除该记录, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          var data = {
            log_ids: this.rklistid,
            token: localStorage.getItem("token"),
          };
          postData("godown.Log/del_sq", data).then((res) => {
            console.log(res, 6666666);
            this.$message({
              type: "success",
              message: "删除成功!",
            });
            this.rukulist();
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    //添加产品明细
    tjcplist() {
      this.form.product_detail = [];
      this.rukumingxi = true;
    },
    threeYearsAfter(val) {
      console.log(val)
      if (val == undefined) {
        const currentDate = new Date();
        console.log(currentDate)
        // let currentDate = now.setFullYear(now.getFullYear() + 3);
        let year = currentDate.getFullYear() + 3;
        let month = currentDate.getMonth() + 1; // 注意月份从0开始，需要加1
        let day = currentDate.getDate() - 1;
        this.form.exp_date = year + "-" + month + "-" + day;
      } else {
        // const currentDate = val;
        const date = new Date(val);
      // date.setFullYear(date.getFullYear() + 3);
      // return date.toISOString().split('T')[0]; // 格式化输出为YYYY-MM-DD
        // let currentDate = now.setFullYear(now.getFullYear() + 3);
        let year = date.getFullYear() + 3;
        let month = date.getMonth() + 1; // 注意月份从0开始，需要加1
        let day = date.getDate();
        this.form.exp_date = year + "-" + month + "-" + day;
      }
      console.log(val);
      console.log(this.form.exp_date);
    },
    //选中
    handleSelectionChange(val) {
      console.log(val);
      // var list = []
      // val.forEach(item => {
      //   list.push({
      //     product_type_id:item.product_type_id,
      //     "product_specifications_id":item.id,
      //     "specification_number":item.specification_number,
      //     "num":item.count,
      //     "remark":item.remark
      //   })
      // });
      // this.form.product_detail = val
      this.xuanzhonlist = val;
      console.log(this.form.product_detail);
      this.form.total_num = this.xuanzhonlist
        .map((row) => row.num * 1)
        .reduce((total, num) => total + num);
    },
    //单独选中
    handleSelectionChangea(val) {
      console.log(val);

      this.xuanzhonlistdd = val;
      console.log(this.form.product_detail);
    },
    quedintijao() {
      this.diaxuanzhe = false;
      this.form.product_detail = this.xuanzhonlist;
    },
    quedintijaoa() {
      this.rukumingxi = false;
      var data = {
        id: this.rklistid,
        product_detail: JSON.stringify(this.xuanzhonlistdd),
        token: localStorage.getItem("token"),
      };
      postData("/godown.log/addProduct", data).then((res) => {
        console.log(res, 6666666);
        this.cpggliistdata = res.data;
      });
    },
    handleNodeClick(data) {
      console.log(data);
      this.cplistxq(data.id);
      this.form.product_type_id = data.id;
      this.dialogVisiblexiolie = false;
    },
    cplist() {
      var data = {
        token: localStorage.getItem("token"),
      };
      postData("product.type/indexlist", data).then((res) => {
        console.log(res, 6666666);
        this.datacplx = res.data;
      });
    },
    //入库申请
    dialogVisiblerkqs() {
      this.dialogVisible = true;
      this.form.start_number = "";
      this.product_type = "";
      this.datacpxl_li = "";
      this.datacpxl_lizj = "";
      this.specifications_list = "";
    },
    //申请入库
    sqruku() {
      var data = {
        log_type: this.form.log_type,
        type: this.form.type,
        rk_time: this.form.rk_time,
        batch_number: this.form.batch_number,
        production_data: this.form.production_data,
        mj_date: this.form.mj_date,
        exp_date: this.form.exp_date,
        year_xlh: this.form.year_xlh,
        pr_mj: this.form.pr_mj,
        start_number: this.form.start_number,
        product_type_id: this.form.product_type_id,
        product_codes_id: this.form.product_codes_id,
        total_num: this.form.total_num,
        remark: this.form.remark,
        product_detail: JSON.stringify(this.form.product_detail),
        token: localStorage.getItem("token"),
      };
      console.log(data);
      postData("godown.Log/operation", data).then((res) => {
        console.log(res, 6666666);
        this.dialogVisible = false 
        this.rukulist()
      });
    },
    //入库申请产品类型详情
    cplistxq(e) {
      var data = {
        product_type_id: e,
        token: localStorage.getItem("token"),
      };
      postData("godown.Log/getproductTypeInfo", data).then((res) => {
        this.form.start_number = res.data.info.next_lsh;
        this.product_type = res.data.codelist;
        this.datacpxl_li = res.data.product_info;
        this.datacpxl_lizj = res.data.product_info.children;
        this.specifications_list = res.data.specifications_list;
      });
    },
    //单独添加入库申请
    //产品类型详情
    cplistxqa(e) {
      var data = {
        product_type_id: e,
        token: localStorage.getItem("token"),
      };
      postData("godown.Log/getproductTypeInfo", data).then((res) => {
        this.form.start_numbera = res.data.info.next_lsh;
        this.product_typea = res.data.codelist;
        this.datacpxl_lia = res.data.product_info;
        this.datacpxl_lizja = res.data.product_info.children;
        this.specifications_lista = res.data.specifications_list;
      });
    },
    //入库申请默认第一条
    setCurrent() {
      this.$refs.singleTable.setCurrentRow(this.tableData[0]);
    },
    //添加产品明细
    cpmxdiaxuanzhe() {
      if (this.form.start_number == "") {
        this.$message({
          message: "您还没有选择产品类型",
          type: "warning",
        });
      } else {
        this.diaxuanzhe = true;
      }
    },

    //提交默认时间
    currentDate() {
      let currentDate = new Date();
      let year = currentDate.getFullYear();
      let month = currentDate.getMonth() + 1; // 注意月份从0开始，需要加1
      let day = currentDate.getDate();
      let hour = currentDate.getHours(); //获取当前小时数(0-23)
      let minute = currentDate.getMinutes(); //获取当前分钟数(0-59)
      let second = currentDate.getSeconds(); //获取当前秒数(0-59)
      this.form.rk_time =
        year +
        "-" +
        month +
        "-" +
        day +
        " " +
        hour +
        ":" +
        minute +
        ":" +
        second;
      this.form.production_data = year + "-" + month + "-" + day;
      this.form.mj_date = year + "-" + month + "-" + day;
      this.rukudata = year + "-" + month + "-" + day;
      console.log(this.form.rk_time);
      return year + "-" + month + "-" + day;
    },

    shengcheng() {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          var data = {
            log_id: this.rklistid,
            token: localStorage.getItem("token"),
          };
          console.log(data);
          postData("godown.Log/clear_detail", data).then((res) => {
            this.$message({
              type: "success",
              message: "删除成功!",
            });
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    rukulist() {
      var data = {
        page: this.currentPage,
        limit: this.pageSize,
        token: localStorage.getItem("token"),
      };
      postData("godown.Log/indexlist", data).then((res) => {
        console.log(res);
        this.tableData = res.data.data;
        this.total = res.data.total;
        this.setCurrent();
      });
    },
    onSubmit() {
      console.log("submit!");
    },
    handleClose(done) {
      done();
      // this.$confirm('确认关闭？')
      // 	.then(_ => {
      // 		done();
      // 	})
      // 	.catch(_ => {});
    },

    handleClick(row) {
      console.log(row);
    },
    handleSizeChange(val) {
      this.pageSize = val;
      this.rukulist();
      console.log(val);
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      console.log(val);
      this.rukulist();
    },
    handleSizeChangea(val) {
      this.pageSizea = val;
    },
    handleCurrentChangea(val) {
      this.currentPagea = val;
    },
  },
};
</script>

<style lang="scss" scoped>
.ipt_a {
  width: 240px;
  height: 50px;
  float: left;
}

.ipt_aa {
  width: 400px;
  height: 50px;
  float: left;
}

.ipt_b {
  width: 450px;
  height: 50px;
  float: left;
}

.listdizhi {
  width: 100%;
  height: 100px;
  float: left;
  border-bottom: 1px solid;
}

.lie {
  width: 90%;
  height: 100%;
  float: left;
}

.listdizhia {
  width: 100%;
  height: 50px;
  float: left;
}

.listdizhia div {
  float: left;
  margin-left: 30px;
}
</style>